#define _GNU_SOURCE

#include <stdlib.h>
#include "app_pool.h"
#include "log/log.h"
#include <unistd.h> // sleep

int task_fun(void *arg)
{
    log_debug("线程%d执行任务，参数=%s", gettid(), (char *)arg);
}

int main(int argc, char const *argv[])
{
    app_pool_init(5); // 初始化线程池，3个线程

    // 注册任务
    for (int i = 0; i < 10; i++)
    {
        char *arg = malloc(10);
        sprintf(arg, "task-%d", i);
        app_pool_registerTask(task_fun, arg);
    }

    sleep(10); // 等待任务执行完毕

    app_pool_destroy(); // 销毁线程池

    return 0;
}